Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented type casting #662

Merged
merged 4 commits into from
Aug 26, 2019
Merged

Implemented type casting #662

merged 4 commits into from
Aug 26, 2019

Conversation

dutor
Copy link
Contributor

@dutor dutor commented Jul 19, 2019

This pr implements and fixes #637

whitewum
whitewum previously approved these changes Jul 19, 2019
@@ -40,11 +40,11 @@ TEST_F(YieldTest, Basic) {
}
{
cpp2::ExecutionResponse resp;
std::string query = "YIELD 1+1";
std::string query = "YIELD 1+1, '1+1', (int)3.14, (string)(1+1), (string)true";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1+1 < 3

@dutor dutor added the ready-for-testing PR: ready for the CI test label Jul 21, 2019
@nebula-community-bot
Copy link
Member

Unit testing passed.

return boost::get<int64_t>(value);
case 1:
return static_cast<int64_t>(boost::get<double>(value));
case 3:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case 2 and case 3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shame on me.

switch (value.which()) {
case 0:
return folly::to<std::string>(boost::get<int64_t>(value));
case 1:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use micro?

@nebula-community-bot
Copy link
Member

Unit testing passed.

laura-ding
laura-ding previously approved these changes Jul 23, 2019
Copy link
Contributor

@laura-ding laura-ding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done

@nebula-community-bot
Copy link
Member

Unit testing passed.

@nebula-community-bot
Copy link
Member

Unit testing failed.

@dutor
Copy link
Contributor Author

dutor commented Jul 25, 2019

Jenkins, go

@nebula-community-bot
Copy link
Member

Unit testing passed.

laura-ding
laura-ding previously approved these changes Jul 25, 2019
return boost::get<bool>(value) ? 1.0 : 0.0;
case 3:
// TODO(dutor) error handling
return folly::to<double>(boost::get<std::string>(value));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think folly::tryTo would be better here, or exception would occur if an unparseable string is provided.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will address such problems after #669 is merged.

case 2:
return boost::get<bool>(value) ? 1.0 : 0.0;
case 3:
return boost::get<int64_t>(value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should do type casting here, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this was a big mistake.

@nebula-community-bot
Copy link
Member

Unit testing passed.

@dutor
Copy link
Contributor Author

dutor commented Aug 14, 2019

@CPWstatic I had resolved the conflicts. But the error handling work mentioned above is not addressed. I am going to do it in the next PR, since there are some additional work to do.

@nebula-community-bot
Copy link
Member

Unit testing passed.

static std::string toString(const VariantType &value) {
char buf[1024];
switch (value.which()) {
case 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the macro from Base.h

@nebula-community-bot
Copy link
Member

Unit testing passed.

@dutor dutor merged commit 303123a into vesoft-inc:master Aug 26, 2019
@dutor dutor deleted the fix-type-casting branch August 26, 2019 06:10
yixinglu pushed a commit to yixinglu/nebula that referenced this pull request Feb 16, 2020
* Implemented type casting

* Address @laura-ding's comments

* Address comments
tong-hao pushed a commit to tong-hao/nebula that referenced this pull request Jun 1, 2021
* Implemented type casting

* Address @laura-ding's comments

* Address comments
liwenhui-soul pushed a commit to liwenhui-soul/nebula that referenced this pull request May 10, 2022
* invalidate empty key cache

* address comment

Co-authored-by: Doodle <13706157+critical27@users.noreply.github.com>
Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type Conversion crash
6 participants